/**
 * This function checks submits a form 
 *
 ***************************************************************
 *  Example
 **************************************************************
 * // attach this even handler onto the submit event for form 
 * $( "#form" ).submit( login_submit_event );
 *  
 **************************************************************
 *
 * @author nicholas malacarne <nicholas.malacarne@gmail.com>
 */

// load dependancies -nm
$.loadScript( "js/ajax/login.ajax.js" );
$.loadScript( "js/filters/login.filter.js" );
$.loadScript( "js/md5.js" );

function login_submit_event( event ){
    
    // username and password values -nm
    var data = {};
    
   // prevent default action of event -nm
   event.preventDefault();
   
   data.username = $( '#username' ).val();
   
   data.password = hex_md5( $( "#password" ).val() );
   
   login_ajax( data ).done( login_filter );
   
//   login_ajax( data ).done(function(d){
//       
//       console.log(d);
//   });
   
//   if ( $.inputOK() ){
//       
//       data.username = $( '#username' ).val();
//       data.password = hex_md5( $( '#password' ).val() );
//       
//       login_ajax( data ).done( function(){
//           
//           // reload page -nm
//           location.reload(true);
//       } );
//   }
};